<template>
    <el-dropdown trigger="click" @command="handleSetLanguage">
        <i :class="'iconfont icon-zhongyingwen'"></i>
        <template #dropdown>
            <el-dropdown-menu>
                <el-dropdown-item  :disabled="locale === 'zhCn'"  command="zhCn">简体中文</el-dropdown-item>
                <el-dropdown-item  :disabled="locale === 'en'"  command="en">English</el-dropdown-item>
            </el-dropdown-menu> 
        </template>
    </el-dropdown>
</template>
<script setup>
import { onMounted } from '@vue/runtime-core'
import { useI18n } from 'vue-i18n'
import { useStore } from 'vuex'
const { locale } = useI18n()
const store = useStore()
const handleSetLanguage = (command) => {
    locale.value = command
    store.commit('changeLang',command)
}
onMounted(() => {
     handleSetLanguage(locale.value)
})
</script>